package com.ybl.wallet.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.ybl.wallet.entity.Transactions;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.Date;
import java.util.List;

@Mapper
public interface WalletMapper extends BaseMapper {

    @Select("SELECT balance FROM wallets WHERE user_id = #{userId}")
    double getBalance(@Param("userId") Long userId);

    @Update("UPDATE wallets SET balance = balance - #{amount} WHERE user_id = #{userId}")
    int updateBalance(@Param("userId") Long userId, @Param("amount") double amount);


}
